package com.dailyblue.java.boot.mybatisplus.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DataBaseDefaultHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("准备给loc属性赋予默认值，值是`西安`！");
        this.strictInsertFill(metaObject, "loc", () -> "西安", String.class);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject,"",()->"",String.class);
    }
}
